//
//  FWTagButton.m
//  BirdLoveSheep
//
//  Created by wwj on 16/4/18.
//  Copyright © 2016年 wwj. All rights reserved.
//

#import "FWTagButton.h"

@implementation FWTagButton

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView{
    [self setTitleColor:MyColor(142, 198, 240) forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:@"chose_tag_close_icon"] forState:UIControlStateNormal];
    self.titleLabel.font = [UIFont systemFontOfSize:14];
    self.backgroundColor = [UIColor whiteColor];
    self.layer.borderColor = MyColor(142, 198, 240).CGColor;
    self.layer.cornerRadius = 4;
    self.layer.borderWidth = 1;
}

- (void)setTitle:(NSString *)title forState:(UIControlState)state{
    [super setTitle:title forState:state];
    [self sizeToFit];
    self.height = TAGWITH;
    self.width += 3 * TAGPADING;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.titleLabel.x = TAGPADING;
    self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) + TAGPADING;
}

@end
